<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="utf-8">
    <title>栏目管理</title>
    <link rel="stylesheet" href="css/bootstrap.min.css"/>
    <script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath }/js/bootstrap.min.js"></script>

    <script type="text/javascript">

        function doDelete() {
            /* 如果这里弹出的对话框，用户点击的是确定，就马上去请求Servlet。
            */
            var cid = $("input:checkbox:checked").val();
            var flag = confirm("是否确定删除?" + cid);
            if (flag) {
                //表明点了确定。 访问servlet。 在当前标签页上打开 超链接，
                //window.location.href="DeleteServlet?sid="+sid;
                location.href = "DeleteColumnServlet?id=" + cid;
            }
        }
    </script>

    <style>
        .table th, .table td {
            text-align: center;
            vertical-align: middle !important;
        }

        .col-md-12 {
            padding-top: 1.25rem;
        }
    </style>
</head>
<body>
<div class="container-fluid">
    <!-- 标题 -->
    <div class="col-md-11">
        <h3>栏目管理</h3>
    </div>
    <!-- 分割线 -->
    <div class="divider">
        <HR
                style="FILTER: alpha(opacity = 100, finishopacity = 0, style = 3)"
                width="90%" color=#987cb9 SIZE=3 align=center>
    </div>
    <div class="col-md-8"></div>
    <div class="col-md-4 text-right">
        <a href="#" class="btn btn-success" data-toggle="modal" data-target="#exampleModal"
           data-whatever="@getbootstrap">添加栏目</a>
        <a href="#" class="btn btn-danger" onclick="doDelete()">删除</a>
    </div>

    <form action="ColumnServlet" method="post">
        <div class="col-md-12">
            <table width="100%"
                   class="table table-bordered table-striped table-hover">
                <tr>
                    <td><input type="checkbox"/></td>
                    <%--                    <td><input type="hidden" value="id"></td>--%>
                    <td>栏目</td>
                    <td>添加时间</td>
                    <td>文章数</td>
                </tr>
                <c:forEach items="${pageBean.list }" var="list">
                    <tr>
                        <td><input type="checkbox" value="${list.id}" name="cid"/></td>
                            <%--                        <td><input type="hidden" value="${list.id}"></td>--%>
                        <td>${list.colum }</td>
                        <td>${list.addtime }</td>
                        <td>${list.number }</td>
                    </tr>
                </c:forEach>
            </table>
        </div>
    </form>
</div>


<%--模态框--%>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">

            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="exampleModalLabel">添加栏目</h4>
            </div>
            <form action="AddColumnServlet" method="post">
                <div class="modal-body">

                    <div class="form-group">
                        <label for="recipient-title" class="control-label">标题:</label>
                        <input type="text" class="form-control" id="recipient-title" name="title">
                    </div>
                    <!-- <div class="form-group">
                      <label for="message-text" class="control-label">Message:</label>
                      <textarea class="form-control" id="message-text"></textarea>
                    </div> -->

                </div>

                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="submit" class="btn btn-primary">提交</button>
                    <%--                <input type="submit" class="btn btn-primary">--%>
                </div>

            </form>
        </div>
    </div>
</div>


<!--分页 -->
<div>
    <nav style="text-align: center;" aria-label="Page navigation" class="navbar-fixed-bottom">
        <ul class="pagination ">

            <c:if test="${pageBean.currentPage !=1 }">
                <li>
                    <a href="ColumnServlet?currentPage=${pageBean.currentPage-1 }" aria-label="Previous">
                        <span aria-hidden="tru">&laquo;上一页</span>
                    </a>
                </li>
            </c:if>

            <li>
                <c:forEach begin="1" end="${pageBean.totalPage }" var="i">
                    <c:if test="${pageBean.currentPage == i }">
                        <a href="#">${i }</a>
                    </c:if>
                    <c:if test="${pageBean.currentPage != i }">
                        <a href="ColumnServlet?currentPage=${i }">${i }</a>
                    </c:if>
                </c:forEach>
            </li>
            <li>
                <c:if test="${pageBean.currentPage !=pageBean.totalPage }">
                    <a href="ColumnServlet?currentPage=${pageBean.currentPage+1 }" aria-label="Next">
                        <span aria-hidden="true">下一页&raquo;</span>
                    </a>
                </c:if>
            </li>
        </ul>
    </nav>
</div>
</body>
</html>
